package com.market.cash.base;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;

import com.market.cash.R;

public abstract class BaseDialog extends Dialog implements View.OnClickListener {

    public BaseDialog(Context context) {
        super(context, R.style.DialogTheme);
    }

    public BaseDialog(Context context, int style) {
        super(context, style);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getRootView());
        initWindow();
        initView();
        initListener();
        initData();
    }

    protected abstract View getRootView();

    /**
     * 初始化Window
     */
    protected abstract void initWindow();

    /**
     * 初始化布局
     */
    protected abstract void initView();

    /**
     * 初始化监听
     */
    protected abstract void initListener();

    /**
     * 初始化数据
     */
    protected abstract void initData();

    /**
     * 控件点击事件
     */
    protected abstract void onViewClick(View v);

    @Override
    public void onClick(View v) {
        onViewClick(v);
    }

    protected void setOnClickListener(View view) {
        view.setOnClickListener(this);
    }
}
